$(function(){
//	模态框的显示
	//这里必须是给未来绑定点击事件，因为修改地地址的时候是异步是实现的。
	$('.btn').live('click',function(){
		$('.modle').show();
	});
	$('.bt').live('click',function(){
		$('.modle').hide();
	});
//	模态框结束
//异步实现对收货地址的修改
	$('.dm').click(function(){
		//获得当前点击删除的adid
		var adid=$(this).attr('adid');
		//然后异步将这个adid传送到php处理返回要添加在表单的旧数据
		$.ajax({
			type:"post",
			url:"index.php?m=home&c=acceptAdd&a=ajaxedit",
			data:{adid:adid},
			dataType:'json',
			success:function(phpdata){
/*
 
 * <div class="form">
		<div class="addshou">添加收货地址
			<input type="button" value="" class="bt" />
		</div>
		<div class="boxb">
			<div class="box">
				<p class="zi"><span style="color: red;">*</span>收货人:</p>
				<input type="text" name="acceptpeople" id="" class="text" rule="required" msg="收件人必须填" />
			</div>
			<div class="box">
				<p class="zi"><span style="color: red;">*</span>所在地区:</p>
				<select name="wherefrom[]" id="area1"></select>											
				<select name="wherefrom[]" id="area2"></select>											
				<select name="wherefrom[]" id="area3"></select>												
			</div>
			<div class="box">
				<p class="zi"><span style="color: red;">*</span>详细地址:</p>
				<input type="text" name="detailadd" id="" class="text addtext" rule="required" msg="详细地址不得为空" />
			</div>
			<div class="box">
				<p class="zi"><span style="color: red;">*</span>邮箱:</p>
				<input type="text" name="email" id="" class="text addtext" rule="required|email" msg="邮箱必须填写|必须是邮箱" />
			</div>
			<div class="box">
				<div class="left">
					<p class="zi"><span style="color: red;">*</span>手机号:</p>
					<input type="text" name="phone[]" id="" class="text" rule="mobile" msg="手机号码不正确"/>
				</div>
				<p class="p">或</p>
				<div class="right">
					<p class="zi">固定电话:</p>
					<input type="text" name="phone[]" id="" class="text" rule="tel" msg="固话不正确"/>
				</div>
			</div>
			<div class="box">
				<p class="zi"><span style="color: red;">*</span>地址别名:</p>
				<input type="text" name="otheradd" id="" class="text bieming" rule="required" msg="地址别名不得为空" />
				<span class="sug">建议填写常用名称 </span>
				<a href="javascript:;" class="bie">家里</a>
				<a href="javascript:;" class="bie">父母家</a>
				<a href="javascript:;" class="bie">公司</a>
			</div>
			<input type="hidden" name="homeuser_uid"  value="{{$_SESSION['uid']}}"/>
			<input type="hidden" class="editcss" name="adid" value=''/>
			<input type="submit" value="保存收货地址" class="sub" />
		</div>
	</div>

 */
				
				
				
				//组合字符串,将获得的数填写到对应的地方，之后添加到页面中去
				var str='<div class="form">'+
							'<div class="addshou">添加收货地址'+
								'<input type="button" value="" class="bt" />'+
							'</div>'+
							'<div class="boxb">'+
								'<div class="box">'+
									'<p class="zi">'+
										'<span style="color: red;">*</span>收货人:'+
									'</p>'+
									'<input type="text" name="acceptpeople" id="" value="'+phpdata.acceptpeople+'" class="text" rule="required" msg="收件人必须填" />'+
								'</div>'+
								'<div class="box">'+
									'<p class="zi"><span style="color: red;">*</span>所在地区:</p>'+
									'<input type="text" class="text" name="" id="" value="'+phpdata.wherefrom+'"/>'+	
									'<span>这里填写省，县，乡的时候用英文逗号隔开</span>'+
								'</div>'+
								'<div class="box">'+
									'<p class="zi"><span style="color: red;">*</span>详细地址:</p>'+
									'<input type="text" name="detailadd" id="" value="'+phpdata.detailadd+'" class="text addtext" rule="required" msg="详细地址不得为空" />'+
								'</div>'+
								'<div class="box">'+
									'<p class="zi"><span style="color: red;">*</span>邮箱:</p>'+
									'<input type="text" name="email" id="" value="'+phpdata.email+'" class="text addtext" rule="required|email" msg="邮箱必须填写|必须是邮箱" />'+
								'</div>'+
								'<div class="box">'+
										'<div class="left">'+
											'<p class="zi"><span style="color: red;">*</span>手机号:</p>'+
											'<input type="text" name="phone[]" value="'+phpdata.phone[0]+'" id="" class="text" rule="mobile" msg="手机号码不正确"/>'+
										'</div>'+
										'<p class="p">或</p>'+
										'<div class="right">'+
											'<p class="zi">固定电话:</p>'+
											'<input type="text" name="phone[]" value="'+phpdata.phone[1]+'" id="" class="text" rule="tel" msg="固话不正确"/>'+
										'</div>'+
								'</div>'+
								'<div class="box">'+
									'<p class="zi"><span style="color: red;">*</span>地址别名:</p>'+
									'<input type="text" name="otheradd" value="'+phpdata.otheradd+'" id="" class="text bieming" rule="required" msg="地址别名不得为空" />'+
									'<span class="sug">建议填写常用名称 </span>'+
									'<a href="javascript:;" class="bie">家里</a>'+
									'<a href="javascript:;" class="bie">父母家</a>'+
									'<a href="javascript:;" class="bie">公司</a>'+
								'</div>'+
								'<input type="hidden" name="homeuser_uid"  value="'+phpdata.homeuser_uid+'"/>'+
								'<input type="hidden" class="editcss" name="adid" value="'+phpdata.adid+'"/>'+
								'<input type="submit" value="保存收货地址" class="sub" />'+
							'</div>'+
						'</div>'
					//将组合的字符串添加懂啊页面中去
					$('.modle form').html(str);
			}
		});
		
		//让模态框出现
		$('.modle').css({display:'block'});
	})

})
